<template>
      <article class="sign">
        <div class="signcon">
          <div class="logo">
            <img src="../../assets/images/logo2.png" alt="" />
          </div>
          <form action="#" class="ouser">
            <p><input type="text" placeholder="手机号"  v-model="user.phone"/></p>
            <p>
              <input type="text" placeholder="密码" v-model="user.password"/>
            </p>
            <input type="submit" value="登录" @click="submit()" />
          </form>
        </div>
      </article>
</template>
<script>
import {Toast} from 'vant';
import {login} from '../../request/api.js'
import {mapActions,mapGetters} from "vuex"
export default {
  data() {
    return {
      user:{
        phone:"",
        password:""
      }
    };
  },
  methods: {
    ...mapActions({
        asyncUserInfo:"asyncUserInfo"
    }),
    submit(){
      login(this.user).then(res=>{
          if(res.data.code == 200){
            // 登录成功的提示
            Toast.success(res.data.msg);
            this.asyncUserInfo(res.data.list)
            this.$router.push("/index")
          }else{
            // 登录失败的提示
            Toast.fail(res.data.msg);
          }
        })
    }

  },
  computed:{
    ...mapGetters({
        userInfo:"userInfo"
    })
  },
  components: {},
  mounted() {},
  destroyed() {},
};
</script>
<style scoped>
@import url(../../assets/css/public.css);
@import url(../../assets/css/sign.css);
</style>